package com.travelparadise.formbeans;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.faces.model.SelectItem;

import com.travelparadise.domain.Commande;
import com.travelparadise.domain.Reservation;
import com.travelparadise.domain.Ville;
import com.travelparadise.service.CommandeService;
import com.travelparadise.service.VilleService;

public class CommandeBean {

	private CommandeService commandeService;
	private VilleService villeService;
	private Set<SelectItem> reservationList;
	private int reservationToDelete;
	private int reservationToModify;
	
	private String idVilleDepart;
	private String idVilleDestination;
	private String nomVilleDepart;
	private String nomVilleDestination;
	
	private List<Reservation> reservations;
	
	private Commande commande;
	
	public CommandeBean(){
		commande = new Commande();
	}
	
	public void findReservationsByIdCommande(int idCommande){
		reservationList = new HashSet<SelectItem>();
		
		for(Reservation reservation : commandeService.findReservationsByIdCommande(idCommande)){
			SelectItem si = new SelectItem();
			reservationList.add(si);
		}
	}
	
	public String selectionVilles(){
		System.out.println(idVilleDepart);
		System.out.println(idVilleDestination);
		
		Ville villeDepart = villeService.getById(Integer.parseInt(idVilleDepart));
		Ville villeDestination = villeService.getById(Integer.parseInt(idVilleDestination));
		nomVilleDepart = villeDepart.getNom();
		nomVilleDestination = villeDestination.getNom();
		
		return "success";
	}
	
	public VilleService getVilleService() {
		return villeService;
	}

	public void setVilleService(VilleService villeService) {
		this.villeService = villeService;
	}

	public String getIdVilleDepart() {
		return idVilleDepart;
	}

	public void setIdVilleDepart(String idVilleDepart) {
		this.idVilleDepart = idVilleDepart;
	}

	public String getIdVilleDestination() {
		return idVilleDestination;
	}

	public void setIdVilleDestination(String idVilleDestination) {
		this.idVilleDestination = idVilleDestination;
	}

	public String getNomVilleDepart() {
		return nomVilleDepart;
	}

	public void setNomVilleDepart(String nomVilleDepart) {
		this.nomVilleDepart = nomVilleDepart;
	}

	public String getNomVilleDestination() {
		return nomVilleDestination;
	}

	public void setNomVilleDestination(String nomVilleDestination) {
		this.nomVilleDestination = nomVilleDestination;
	}

	public int getReservationToModify() {
		return reservationToModify;
	}

	public void setReservationToModify(int reservationToModify) {
		this.reservationToModify = reservationToModify;
	}

	public int getReservationToDelete() {
		return reservationToDelete;
	}

	public void setReservationToDelete(int reservationToDelete) {
		this.reservationToDelete = reservationToDelete;
	}

	public CommandeService getCommandeService() {
		return commandeService;
	}

	public void setCommandeService(CommandeService commandeService) {
		this.commandeService = commandeService;
	}

	public Set<SelectItem> getReservationList() {
		return reservationList;
	}

	public void setReservationList(Set<SelectItem> reservationList) {
		this.reservationList = reservationList;
	}

	public List<Reservation> getReservations() {
		return reservations;
	}

	public void setReservations(List<Reservation> reservations) {
		this.reservations = reservations;
	}

	public Commande getCommande() {
		return commande;
	}

	public void setCommande(Commande commande) {
		this.commande = commande;
	}
	
	
}
